package myTest;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

import com.mysql.fabric.xmlrpc.base.Data;


public class ThreadTest{
	static ExecutorService executorService = Executors.newFixedThreadPool(5);
	public static void main(String[] args) {
		List<Future<String>> list = new ArrayList<Future<String>>();
		for(int i = 0 ;i <1 ;i++){
			try{
				list.add(executorService.submit(new Callable<String>() {
					@Override
					public String call() throws Exception{
						Thread.sleep(10000);
						throw new Exception("手动异常");
						//return "ss";
					}
				}));
			}catch(Exception e){
				System.err.println("捕获到线程内部错误"+new Date());
			}finally{
				System.err.println("执行finally");
			}
			
		}
	System.out.println("完成");
	System.out.println(list.size());
	try {
		System.out.println(list.get(0).get());
	} catch (InterruptedException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	} catch (ExecutionException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	}
}

/*class ThreadA{
	
	public synchronized void ss(){
		System.out.println("begin");
		try {
			Thread.sleep(100000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		System.out.println("end");

	}
}*/

